/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view.GUI.actions;

import java.awt.Color;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import model.graphic.GraphicModel;
import model.graphic.objects.GTrigger;
import model.graphic.objects.Graphical;
import view.GUI.graphic.GraphicView;

/**
 *
 * @author Arfeniel
 */
public class SetTriggerAction extends AbstractAction{

    private GraphicModel gmodel;
    private GraphicView gview;
    private GTrigger trigger;

    public SetTriggerAction(GraphicModel gmodel) {
        this.gmodel = gmodel;
    }

    public SetTriggerAction(GraphicView gview, GraphicModel gmodel, Graphical selected) {
        this.gmodel=gmodel;
        this.gview=gview;
        this.trigger=(GTrigger) selected;
    }

    public void actionPerformed(ActionEvent e) {
        if(gmodel.isMainTriggerSet()){
            gmodel.getMainTrigger().setBackColor(Color.WHITE);
        }
        gmodel.setMainTrigger(trigger);
        trigger.setBackColor(Color.GREEN);
        gview.repaint();
    }
}
